package com.biu.billiards.controller;


import com.biu.billiards.model.vo.hardware.AddHardwareVo;
import com.biu.billiards.model.vo.hardware.GetHardwareVo;
import com.biu.billiards.model.vo.hardware.UpdateHardwareVO;
import com.biu.billiards.model.vo.shop.AddShopVo;
import com.biu.billiards.model.vo.shop.GetShopVo;
import com.biu.billiards.model.vo.shop.UpdateShopVO;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.IGoodsService;
import com.biu.billiards.service.IHardwareService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-11-11
 */
@RestController
@RequestMapping()
public class HardwareController {

    @Resource
    private IHardwareService hardwareService;


    @ApiOperation(value = "获取控制器数据")
    @PostMapping("/getHardwarePage")
    public BaseResponse<Map<String,Object>> getHardwarePage(@RequestBody GetHardwareVo getHardwareVo) {
        return RespGenerator.returnOK(hardwareService.getHardwarePage(getHardwareVo));
    }


    @ApiOperation(value = "修改控制器信息")
    @PutMapping("/updateHardware")
    public BaseResponse<Boolean> updateHardware(@RequestBody UpdateHardwareVO updateHardwareVO) {
        return RespGenerator.returnOK(hardwareService.updateHardware(updateHardwareVO));
    }


    @ApiOperation(value = "新增控制器信息")
    @PostMapping("/addHardware")
    public BaseResponse<Boolean> addHardware(@RequestBody AddHardwareVo addHardwareVo) {
        return RespGenerator.returnOK(hardwareService.addHardware(addHardwareVo));
    }


    @ApiOperation(value = "删除控制器信息")
    @DeleteMapping("/deleteHardware")
    public BaseResponse<Boolean> deleteHardware(@RequestParam("hardwareId") Integer hardwareId) {
        return RespGenerator.returnOK(hardwareService.deleteHardware(hardwareId));
    }


}
